package com.weiyuwqj.server.service.invest.impl;

import com.github.pagehelper.PageHelper;
import com.weiyuwqj.server.service.base.BaseServiceImpl;
import com.weiyuwqj.server.mapper.BusItemInvestMapper;
import com.weiyuwqj.api.service.BusInvestRecordService;
import com.weiyuwqj.api.common.PageList;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.model.BusItemInvest;
import com.weiyuwqj.api.model.vo.BusItemInvestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by yxw on 2015/12/28.
 */
@Service("investRecordService")
public class BusInvestRecordServiceImp extends BaseServiceImpl<BusItemInvest> implements BusInvestRecordService {
    @Autowired
    BusItemInvestMapper itemInvestMapper;

    @Override
    public PageList getList(Paginator p, Map<String, Object> param) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        List<BusItemInvestVo> list = itemInvestMapper.getList(param);
        return new PageList(list);
    }

    @Override
    public List<BusItemInvestVo> getList(Map<String, Object> param) {
        return itemInvestMapper.getList(param);
    }

    @Override
    public List getInvestByItemId(Integer itemId,Paginator p) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        List list=itemInvestMapper.getInvestByItemId(itemId);
        return list;
    }

    @Override
    public Map countInvestByUserId(Integer userId) {
        return itemInvestMapper.countInvestByUserId(userId);
    }

    @Override
    public PageList getListByUserId(Paginator p,Integer userId) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        return new PageList(itemInvestMapper.getListByUserId(userId));
    }
}
